package com.jy.adscm.operation.hscrb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.hscrb.bean.MjSterilizationdetail;
import com.jy.adscm.operation.hscrb.mapper.mysql.MjSterilizationdetailMapper;
import com.jy.adscm.operation.hscrb.service.MjSterilizationdetailService;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-12-17
 */
@Service
public class MjSterilizationdetailServiceImpl extends ServiceImpl<MjSterilizationdetailMapper, MjSterilizationdetail> implements MjSterilizationdetailService {
    @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public Boolean updateMjSterilizationdetail(MjSterilizationdetail mjSterilizationdetail) {
        boolean result = super.updateById(mjSterilizationdetail);
        return result;
    }

    @Override
    public List<MjSterilizationdetail> selectByTid(String tid) {
        Wrapper<MjSterilizationdetail> wrapper =new EntityWrapper<>();
        wrapper.eq("TID",tid);
        List<MjSterilizationdetail> mjSterilizationdetails = super.selectList(wrapper);
        for (MjSterilizationdetail mjSterilizationdetail : mjSterilizationdetails) {
              if (AdscmBaseUtils.getInstance().isNotEmpty(mjSterilizationdetail.getExceptionboxnums(),null)){
                  JyUser jyUser = jyUserMapper.selectById(mjSterilizationdetail.getExceptionboxnums());
                  mjSterilizationdetail.setExceptionboxnumsName(jyUser.getName());
              }
        }
        return mjSterilizationdetails;
    }
}
